package com.qianfeng.camerademo.utils;

import android.R.integer;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

/**
 * @author: 张唯
 * @类 说 明:
 * @version 1.0
 * @创建时间：2014-10-28 下午10:40:55
 * 
 */
public class ImageUtils {
	public static Bitmap sampBitmap(String imagePath) {
		BitmapFactory.Options options = new BitmapFactory.Options();
		options.inJustDecodeBounds = true;// 处理图片不加载进内存
		BitmapFactory.decodeFile(imagePath, options);
		int height = options.outHeight;
		int width = options.outWidth;
		// 如果图片的默认高度或者宽大于指定的宽或高 我们就等比例压缩
		int inSampleSize = 1;
		if (height / inSampleSize > 100 || width / inSampleSize > 100) {
			inSampleSize *= 2;
		}
		options.inJustDecodeBounds = false;
		options.inSampleSize = inSampleSize;
		return BitmapFactory.decodeFile(imagePath, options);
	}
}
